<?php
require_once "includes/config.php";
session_start();	
	$date=date("Y-m-d");
	$sessid=session_id();
	
	$prod_id=$_GET['id'];
		
	$sqlSelItemUser1="select * from tempcart where session_id ='".$sessid."' and isWhole='0'";
	$rstSelItemUser1=mysql_query($sqlSelItemUser1);
	$rowSelItemUser1=mysql_fetch_array($rstSelItemUser1);
	$url="index.php?wholeproducts=$prod_id";	
	if(is_array($rowSelItemUser1))
	{
		$_SESSION['msg']="Your card having regular items, Please buy the regular items from your card and then add wholesaler items.";
		header("Location: ". $url);
		exit;
	}
			
	$sqlSelItemUser1="select * from tbl_items_code where product_id='".$prod_id."' and isSold='0' and isWhole='1' limit 0,1";
	$rstSelItemUser1=mysql_query($sqlSelItemUser1);
	$rowSelItemUser1=mysql_fetch_array($rstSelItemUser1);
	if(is_array($rowSelItemUser1))
	{
		$code=$rowSelItemUser1['code'];
	}
		
	//echo "insert into tempcart(itemid,itemname,itemamt,session_id,adddate,qty,shipping) values('".$_GET['id']."','".$_GET['name']."','".$_GET['amt']."','".$sessid."','".$date."','1')";	
	mysql_query("insert into tempcart(itemid,itemname,itemamt,session_id,adddate,qty,shipping,sales_tax,item_code,isWhole) values('".$_GET['id']."','".$_GET['name']."','".$_GET['amt']."','".$sessid."','".$date."','".$_GET['qty']."','".$_GET['shipping']."','".$_REQUEST['tax']."','$code','1' )");
	?>
	<script language="javascript1.2">
	location.href="index.php?cart";
	</script>